package com.symria.taglib;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.servlet.jsp.JspException;


import org.apache.struts2.views.jsp.StrutsBodyTagSupport;

import com.symria.framework.util.StringUtil;
import com.symria.role.util.Logger;
import com.symria.system.constants.ATTAdStatus;

public class ParseSelect extends StrutsBodyTagSupport {
	private static final Logger logger = Logger.getLogger(ParseSelect.class);
    private String value;
    private String type;
    

	@Override
	public int doEndTag() throws JspException {
		return EVAL_PAGE;
	}
	@Override
	public int doStartTag() throws JspException {
	    try {
			pageContext.getOut().write(optionsName());
		} catch (IOException e) {
			logger.logError("adstatus tag error:"+e.getMessage());
		}
		return EVAL_BODY_BUFFERED;
	}
	private String optionsName(){
		StringBuffer sBuf = new StringBuffer("");
		if(StringUtil.equals("adCampaign", type)){
			 Map<String, ATTAdStatus> map = ATTAdStatus.statusMap;
			 for(Entry<String, ATTAdStatus> entry: map.entrySet()){
				 sBuf.append("<option value=\""+entry.getValue().toString()+"\"  "+(StringUtil.equals(entry.getValue().toString(), value)?"selected = \"sekected\"":"")+">"+entry.getValue().toName()+"</option>");
			 }
		}
		return sBuf.toString();
	}

	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
	
    

}
